﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TpBaseObjects.Base;
using TpData.Layer;
using TpData.Manager;
using TpLogger;

namespace TpData {
    public class TpSettings {

        #region Members

        private object SyncRoot = new object();
        private System.Collections.Hashtable cache = new System.Collections.Hashtable();

        #endregion

        //public T GetSetting<T>(string xPath, T defaultValue) {
        //    lock (SyncRoot) {
        //        if (!cache.ContainsKey(xPath)) {
        //            T val = GetSettingFromDB<T>(xPath, defaultValue);
        //            cache[xPath] = val;
        //            return val;
        //        }
        //        return (T)cache[xPath];
        //    }
        //}

        //public T GetSettingFromDB<T>(string xPath, T defaultValue) {
        //    SettingsDataManager.LoadSetting(

        //}

        #region Methods

        public void SaveSetting<T>(string xPath, T value) {
            lock (SyncRoot) {
                if (cache.ContainsKey(xPath))
                    cache[xPath] = value;
            }

            SaveSettingToDB<T>(xPath, value);
        }

        public void SaveSettingToDB<T>(string xPath, T defaultValue) {
            
        }

        #endregion
        
    }
}
